// JavaScript Document


//实现返回前一个页面
function GoBack(){
	window.history.back();
}


//onload加载事件,见body标签
function closebi(){
	window.close();
	}
	
	



//时间显示
var dateList = new Array();

var tempDay = new Date();

function changeW(w){
	var tempStr = "";
	try{
		switch(w){
			case 1:tempStr="周一";break;
			case 2:tempStr="周二";break;
			case 3:tempStr="周三";break;
			case 4:tempStr="周四";break;
			case 5:tempStr="周五";break;
			case 6:tempStr="周六";break;
			default:tempStr="周日";break;
		}
	}catch(e){ console.log(e)}
	return tempStr;
}

$(function(){
	var today = 0;
	for(var i=0;i<7;i++){
		if(i==0){
			tempDay = new Date(parseInt($("#val_toDay").val()));
			today = tempDay.getDate();
		}
		else{
			tempDay = new Date(tempDay.getTime()+24*60*60*1000);
		}
		
		var tempDate = tempDay.getDate();//几号
		var tempW = changeW(tempDay.getDay());//周几
		if(today == tempDate){
			tempW = "今天";
		}
		var dateObj = {};
		dateObj["tempDate"] = tempDate;
		dateObj["tempDay"] = tempW;
		dateObj["dateText"] = getDateText(tempDay);
		dateList.push(dateObj);
	}
	
	var isFirst=true;
	$.each(dateList,function(idx,item){
		var date = item.tempDate;
		var day = item.tempDay;
		var dateText = item.dateText;
		var str = "";
		//if("周六"== day || "周日"==day){
		//	str = "<li><span class='s_timelis no' id='day"+idx+"' data-val='"+dateText+"' >"+date+"</span><span class='x_timelis no'>"+day+"</span></li>";
		//}else{
			str = "<li><span class='s_timelis "+(isFirst?"select":"")+"' id='day"+idx+"' onclick=selectTab("+idx+") data-val='"+dateText+"'>"+date+"</span><span class='x_timelis'>"+day+"</span></li>";
			isFirst=false;
		//}
		$("#timelist").append(str);
		});

})
	
function selectTab(idx){
	//$("#day"+idx).css("background","#407ece");
	$(".s_timelis").removeClass("select");
	$("#day"+idx).addClass("select");
	refReserveUI();
}

function getDateText(d){
	var year=d.getFullYear();
	var month=d.getMonth()+1;
	var day = d.getDate();
	return year+'-'+(month<10?'0'+month:month)+'-'+(day<10?'0'+day:day);
}





//今天的时间
/*var nowDate = new Date();
var today = nowDate.getDate();//几号
var todayDay = nowDate.getDay();//周几

var day2 = new Date(nowDate.getTime()+24*60*60*1000);
var day2Date = day2.getDate();
var day2Day = day2.getDay();

var day3 = new Date(nowDate.getTime()+24*60*60*1000*2);
var day3Date = day3.getDate();
var day3Day = day3.getDay();

var day4 = new Date(nowDate.getTime()+24*60*60*1000*3);
var day4Date = day4.getDate();
var day4Day = day4.getDay();

var day5 = new Date(nowDate.getTime()+24*60*60*1000*4);
var day5Date = day5.getDate();
var day5Day = day5.getDay();

var day6 = new Date(nowDate.getTime()+24*60*60*1000*5);
var day6Date = day6.getDate();
var day6Day = day6.getDay();

var day7 = new Date(nowDate.getTime()+24*60*60*1000*6);
var day7Date = day6.getDate();
var day7Day = day6.getDay(); */

 /*var day2 = new Date();
 alert(day2.getDate());
 alert(day2.getDay());
 day2.setTime(day2.getTime());
 var s2 = day2.getFullYear()+"-" + (day2.getMonth()+1) + "-" + day2.getDate();
 
 
 //明天的时间
 var day3 = new Date();
 
 day3.setTime(day3.getTime()+24*60*60*1000);
 var s3 = day3.getFullYear()+"-" + (day3.getMonth()+1) + "-" + day3.getDate();
 
 
  //后天的时间
 var day3 = new Date();
 day3.setTime(day3.getTime()+24*60*60*1000*2);
 var s3 = day3.getFullYear()+"-" + (day3.getMonth()+1) + "-" + day3.getDate();
 
  //后天+1 的时间
 var day3 = new Date();
 day3.setTime(day3.getTime()+24*60*60*1000*3);
 var s3 = day3.getFullYear()+"-" + (day3.getMonth()+1) + "-" + day3.getDate();
 
 
   //后天+2 的时间
 var day3 = new Date();
 day3.setTime(day3.getTime()+24*60*60*1000*4);
 var s3 = day3.getFullYear()+"-" + (day3.getMonth()+1) + "-" + day3.getDate();

  //后天+3 的时间

 var day3 = new Date();
 day3.setTime(day3.getTime()+24*60*60*1000*5);
 var s3 = day3.getFullYear()+"-" + (day3.getMonth()+1) + "-" + day3.getDate();

//后天+4 的时间

 var day3 = new Date();
 day3.setTime(day3.getTime()+24*60*60*1000*6);
 var s3 = day3.getFullYear()+"-" + (day3.getMonth()+1) + "-" + day3.getDate();

	var mycon=document.getElementById("day2");
	document.write("p标签原始内容："+mycon.innerHTML+"<br>");//输入元素内容

	mycon.innerHTML="新内容！";//修改p元素内容
	document.write("p标签修改后内容："+mycon.innerHTML);
	
*/
 